package com.macro.mall.portal.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.macro.mall.mapper.BmsExhibitionsActivitiesGoodsMapper;
import com.macro.mall.mapper.BmsExhibitionsActivitiesMapper;
import com.macro.mall.mapper.BmsExhibitionsActivitiesPicMapper;
import com.macro.mall.model.BmsExhibitionsActivities;
import com.macro.mall.model.BmsExhibitionsActivitiesGoods;
import com.macro.mall.portal.dto.BmsExhibitionsActivitiesDetail;
import com.macro.mall.portal.dto.BmsExhibitionsActivitiesGoodsDetail;
import com.macro.mall.portal.dto.BmsExhibitionsActivitiesGoodsParam;
import com.macro.mall.portal.dto.BmsExhibitionsActivitiesParam;
import com.macro.mall.portal.service.BmsExhibitionsActivitiesService;


/**
 * 展览活动
 * Created by macro on 2018/4/26.
 */
@Service
public class BmsExhibitionsActivitiesServiceImpl implements BmsExhibitionsActivitiesService {

    @Autowired
    private BmsExhibitionsActivitiesMapper bmsExhibitionsActivitiesMapper;

    @Autowired
    private BmsExhibitionsActivitiesGoodsMapper bmsExhibitionsActivitiesGoodsMapper;

    @Autowired
    private BmsExhibitionsActivitiesPicMapper bmsExhibitionsActivitiesPicMapper;



    @Override
    public List<BmsExhibitionsActivities> list(BmsExhibitionsActivitiesParam bmsExhibitionsActivitiesParam) {
        BmsExhibitionsActivities bmsExhibitionsActivities = new BmsExhibitionsActivities();
        BeanUtils.copyProperties(bmsExhibitionsActivitiesParam, bmsExhibitionsActivities);
        List<BmsExhibitionsActivities> list = bmsExhibitionsActivitiesMapper.selectAllXiao(bmsExhibitionsActivities);
        return list;
    }

    @Override
    public BmsExhibitionsActivities detail(Long id) {
        BmsExhibitionsActivities entity = bmsExhibitionsActivitiesMapper.selectXiao(id);
        if (entity == null) {
            return new BmsExhibitionsActivities();
        }
        List<String> picList = bmsExhibitionsActivitiesPicMapper.findByExhibitionsActivitiesId(id);
        entity.setPicList(picList);
        return entity;
    }

    @Override
    public List<BmsExhibitionsActivitiesGoods> goods(BmsExhibitionsActivitiesGoodsParam bmsExhibitionsActivitiesGoodsParam) {
        BmsExhibitionsActivitiesGoods bmsExhibitionsActivitiesGoods = new BmsExhibitionsActivitiesGoods();
        BeanUtils.copyProperties(bmsExhibitionsActivitiesGoodsParam, bmsExhibitionsActivitiesGoods);
        bmsExhibitionsActivitiesGoods.setExhibitionsActivitiesId(bmsExhibitionsActivitiesGoodsParam.getId());
        List<BmsExhibitionsActivitiesGoods> list = bmsExhibitionsActivitiesGoodsMapper.selectAll(bmsExhibitionsActivitiesGoods);
        return list;
    }

    @Override
    public BmsExhibitionsActivities getVR(BmsExhibitionsActivitiesParam bmsExhibitionsActivitiesParam) {
        BmsExhibitionsActivities bmsExhibitionsActivities = new BmsExhibitionsActivities();
        BeanUtils.copyProperties(bmsExhibitionsActivitiesParam, bmsExhibitionsActivities);
        bmsExhibitionsActivities = bmsExhibitionsActivitiesMapper.selectAllXiaoVr(bmsExhibitionsActivities);
        BmsExhibitionsActivitiesDetail detail = new BmsExhibitionsActivitiesDetail();
        if (bmsExhibitionsActivities != null){

            BeanUtils.copyProperties(bmsExhibitionsActivities, detail);
            // 获取活动图片
            List<String> picList = bmsExhibitionsActivitiesMapper.findPicListByActivitiesIdVr(bmsExhibitionsActivities.getId());
            detail.setPicList(picList);
        }
        return detail;
    }

    @Override
    public BmsExhibitionsActivitiesGoods goodsDetail(Long id) {
        BmsExhibitionsActivitiesGoods bmsExhibitionsActivitiesGoods = bmsExhibitionsActivitiesMapper.selectGoodsDetailXiao(id);
        BmsExhibitionsActivitiesGoodsDetail detail = new BmsExhibitionsActivitiesGoodsDetail();
        if (bmsExhibitionsActivitiesGoods != null) {
            BeanUtils.copyProperties(bmsExhibitionsActivitiesGoods, detail);
            // 获取活动图片
            List<String> picList = bmsExhibitionsActivitiesMapper.findPicListByActivitiesId(id);
            detail.setPicList(picList);
        }
        return detail;
    }
}
